const api = require('./api')


    
const update_pilotRank=(that)=>{
    let url_data = {
      jg_stu_id:that.data.stu_info.jg_stu_id,
      photo:that.data.stu_info.photo,
      stu_name:that.data.stu_info.real_name,
      pilot_rank_id:that.data.stu_info.pilot_rank_id,
      jg_id:that.data.stu_info.jg_id,
      page_index_2:that.page_index_1,
    }
    wx.navigateTo({
      url: '/pages/students/stu_register/update_pilotRank/update_pilotRank?url_data=' + encodeURIComponent(JSON.stringify(url_data)),
    })
    that.can_onShow = true
  }
  
const update_uav_level=(that)=>{
    let url_data = {
      jg_stu_id:that.data.stu_info.jg_stu_id,
      photo:that.data.stu_info.photo,
      stu_name:that.data.stu_info.real_name,
      uav_level_id:that.data.stu_info.uav_level_id,
      jg_id:that.data.stu_info.jg_id
    }
    wx.navigateTo({
      url: '/pages/students/stu_register/update_uav_level/update_uav_level?url_data=' + encodeURIComponent(JSON.stringify(url_data)),
    })
    that.can_onShow = true
  }
  
const update_uav_type=(that)=>{
    let url_data = {
      jg_stu_id:that.data.stu_info.jg_stu_id,
      photo:that.data.stu_info.photo,
      stu_name:that.data.stu_info.real_name,
      uav_type_id:that.data.stu_info.uav_type_id,
      jg_id:that.data.stu_info.jg_id
    }
    wx.navigateTo({
      url: '/pages/students/stu_register/update_uav_class/update_uav_class?url_data=' + encodeURIComponent(JSON.stringify(url_data)),
    })
    that.can_onShow = true
  }

const update_license=(that)=>{
    let url_data = {
      jg_stu_id:that.data.stu_info.jg_stu_id,
      photo:that.data.stu_info.photo,
      stu_name:that.data.stu_info.real_name,
      license_id:that.data.stu_info.license_id,
      jg_id:that.data.stu_info.jg_id
    }
    wx.navigateTo({
      url: '/pages/students/stu_register/update_stu_license/update_stu_license?url_data=' + encodeURIComponent(JSON.stringify(url_data)),
    })
    that.can_onShow = true
  }

const update_email=(that, e)=>{
    let url_data = {
      jg_stu_id:that.data.stu_info.jg_stu_id,
      photo:that.data.stu_info.photo,
      stu_name:that.data.stu_info.real_name,
      email:that.data.stu_info.email,
      jg_id:that.data.stu_info.jg_id
    }
    wx.navigateTo({
      url: '/pages/students/stu_register/update_stuEmail/update_stuEmail?url_data=' + encodeURIComponent(JSON.stringify(url_data)),
    })
    that.can_onShow = true
  }


const set_ins=(that, e)=>{
    let url_data = {
      jg_stu_id:that.data.stu_info.jg_stu_id,
      photo:that.data.stu_info.photo,
      stu_name:that.data.stu_info.real_name,
      ins_id:that.data.stu_info.ins_id,
      jg_id:that.data.stu_info.jg_id
    }
    wx.navigateTo({
      url: '/pages/students/stu_register/bind_insToStu/bind_insToStu?url_data=' + encodeURIComponent(JSON.stringify(url_data)),
    })
    that.can_onShow = true
  }
  
// 设置学员标签
const set_label=(that, e)=>{
  let url_data = {
    jg_stu_id:that.data.stu_info.jg_stu_id,
    photo:that.data.stu_info.photo,
    stu_name:that.data.stu_info.real_name,
    label_id:that.data.stu_info.label_id,
    jg_id:that.data.stu_info.jg_id,
  }
  wx.navigateTo({
    url: '/pages/students/stu_register/set_stu_label/set_stu_label?url_data=' + encodeURIComponent(JSON.stringify(url_data)),
  })
  that.can_onShow = true
}

const  update_addr=(that)=>{
  let url_data = {
    jg_stu_id:that.data.stu_info.jg_stu_id,
    photo:that.data.stu_info.photo,
    stu_name:that.data.stu_info.real_name,
    address:that.data.stu_info.address
  }
  wx.navigateTo({
    url: '/pages/students/stu_register/update_stu_addr/update_stu_addr?url_data=' + encodeURIComponent(JSON.stringify(url_data)),
  })
  that.can_onShow = true
}




// 设置学员状态
const set_stu_status=(that,e)=>{
  let url_data = {
    jg_stu_id:that.data.stu_info.jg_stu_id,
    photo:that.data.stu_info.photo,
    stu_name:that.data.stu_info.real_name,
    status_id:that.data.stu_info.status,
    page_index_2:that.page_index_1,
  }
  wx.navigateTo({
    url: '/pages/students/stu_register/set_stu_status/set_stu_status?url_data=' + encodeURIComponent(JSON.stringify(url_data)),
  })
  that.can_onShow = true
}



// 查看图片
const view_photo=(that)=>{
  let photo = that.data.stu_info.photo
  wx.previewImage({
    urls: [photo],
    showmenu: true,
  })
}



  //同意/拒绝
  const review=(that, e)=>{
    let status = e.detail.value
    wx.showModal({
      content: '确定此操作吗？',
      showCancel: true,
      title: status==3?'同意进入班级':status==2?'拒绝！':'',
      success: res => {
        if(res.confirm){
          api.update_stu_status(that,that.data.stu_info.jg_stu_id, status)
        }else{
          that.setData({
            stu_info:that.data.stu_info
          })
        }
      },
    })
}



// 返回
const back=(that)=>{wx.navigateBack()}



module.exports={
  update_pilotRank,
  update_uav_level,
  update_uav_type,
  update_license,
  update_email,
  set_stu_status,
  set_ins,
  set_label,
  update_addr,
  review,
  view_photo,
  back,
}